﻿using System.Collections.ObjectModel;
using MvvmFoundation.Wpf;
using WpfApplication1.TaskModule;
using WpfApplication1.ContactModule;
using WpfApplication1.Wpf;

namespace WpfApplication1
{
    public class MainWindowViewModel : ObservableObject
    {
        private readonly IViewModelResolver _viewModelResolver;
        private ViewModel _mainPane;

        public MainWindowViewModel(IViewModelResolver viewModelResolver)
        {
            _viewModelResolver = viewModelResolver;

            NaviCommands = new ObservableCollection<CommandViewModel>
            {
                new CommandViewModel(ShowTasks) {DisplayName = "Tasks"},
                new CommandViewModel(ShowContacts) {DisplayName = "Contacts"}
            };
        }

        public ObservableCollection<CommandViewModel> NaviCommands { get; private set; }

        public ViewModel MainPane
        {
            get { return _mainPane; }
            private set
            {
                _mainPane = value;
                RaisePropertyChanged("MainPane");
            }
        }

        private void ShowTasks()
        {
            MainPane = _viewModelResolver.Resolve<TasksViewModel>();
        }

        private void ShowContacts()
        {
            MainPane = _viewModelResolver.Resolve<ContactsViewModel>();
        }
    }
}